<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"   
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
 	
 	<h:head>
 		<h:outputStylesheet library="css" name="style.css"/>
 	</h:head>
    <h:body>
    	<h:form>
    	<h:inputText value="#{searchBean.searchText}" styleClass="searchInput"/>
    	<h:commandButton value="Cauta" type="submit" styleClass="searchButton"
    		action="#{searchBean.search()}"/>
    	</h:form>
    	<ui:repeat offset="#{searchBean.pageOffset}" 
    		size="#{searchBean.pageSize}" value="#{searchBean.results}" 
    		var="searchSiteResult">
    	<h:panelGroup layout="block" styleClass="list">
    	<h:outputText value="#{searchSiteResult.siteName}"/><br/>
    	<h:outputLink value="#{searchSiteResult.urlToSite}">
    		Mergi la Site
    	</h:outputLink>
 		<h:dataTable columnClasses="list-item list-item-medium,
  				list-item list-item-large, list-item list-item-small,
				list-item list-item-medium" headerClass="list-header"
 				rowClasses="list-row"
 				value="#{searchSiteResult.listOfResults}" var="searchResult">   
  			<h:column>
    			<f:facet name="header">
      				Nume produs
    			</f:facet>
    			<h:outputText value="#{searchResult.productName}"/>
  			</h:column>
  			<h:column>
    			<f:facet name="header">
      				Descriere
    			</f:facet>
    			<h:outputText value="#{searchResult.description}"/>
  			</h:column>
  			<h:column>
    			<f:facet name="header">
      				Pret
    			</f:facet>
    			<h:outputText value="#{searchResult.price}">
    				<f:convertNumber pattern="#,###.00"/>
    			</h:outputText>
  			</h:column>
  			<h:column>
    			<f:facet name="header">
      				Url
    			</f:facet>
    			<h:outputLink value="#{item.url}">
    				mergi la produs
    			</h:outputLink>
  			</h:column>
		</h:dataTable>
		</h:panelGroup>
		</ui:repeat>
		<br/>
		<h:form>
		<h:commandLink value="&lt;&lt;" action="#{searchBean.firstPage()}"
			disabled="#{searchBean.firstPage}"/>
		<h:outputText value="&nbsp;"/>
		<h:commandLink value="&lt;" action="#{searchBean.previousPage()}"
			disabled="#{searchBean.firstPage}"/>
		<h:outputText value="&nbsp;"/>
		<h:outputText value="#{searchBean.pageNumber}"/>
		<h:outputText value="&nbsp;"/>
		<h:commandLink value="&gt;" action="#{searchBean.nextPage()}" 
			disabled="#{searchBean.lastPage}"/>
		<h:outputText value="&nbsp;"/>
		<h:commandLink value="&gt;&gt;" action="#{searchBean.lastPage()}"
			disabled="#{searchBean.lastPage}"/>
		</h:form>
    </h:body>
</html>